package org.easytouseit.websocket.config;

import org.easytouseit.websocket.handler.SocketHandler;
import org.easytouseit.websocket.interceptor.WebSocketInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @author guojm
 * @version V1.0
 * @date 2019-01-09 上午 10:19
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer{
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
        webSocketHandlerRegistry.addHandler(new SocketHandler(),"/webSocket/{ID}")
                .addInterceptors(new WebSocketInterceptor())
                .setAllowedOrigins("*");
    }
}
